/*
包含n个reducer函数: 根据老的state和指定的action返回一个新的state
 */
import {
  combineReducers
} from "redux";

import {
  RECEIVE_PERSONALIZED_LIST,
  RECEIVE_RANKING_LIST,
  RECEIVE_BILLBOARD,
  RECEIVE_SEARCH,
  RECEIVE_SEARCHHOT,
} from "./action-types";

const initPersonalizedList = [];
// 产生PersonalizedList状态的reducer
function personalizedList(state = initPersonalizedList, action) {
  switch (action.type) {
    case RECEIVE_PERSONALIZED_LIST: //
      return action.data;
    default:
      return state;
  }
}
const initRankingObj = [];
// 产生PersonalizedList状态的reducer
function rankingObj(state = initRankingObj, action) {
  switch (action.type) {
    case RECEIVE_RANKING_LIST: //
      return action.data;
    default:
      return state;
  }
}
const initBillBoard = [];

function billBoard(state = initBillBoard, action) {
  switch (action.type) {
    case RECEIVE_BILLBOARD: //
      return action.data;
    default:
      return state;
  }
}
const initSearchResult = {
  temArr: []
};

function searchResult(state = initSearchResult, action) {
  switch (action.type) {
    case RECEIVE_SEARCH: //
      // console.log('action.data', action.data);
      return action.data;
    default:
      return state;
  }
}
const initSearchHotResult = [];

function searchHotResult(state = initSearchHotResult, action) {
  switch (action.type) {
    case RECEIVE_SEARCHHOT: //
      return action.data;
    default:
      return state;
  }
}
export default combineReducers({
  personalizedList,
  rankingObj,
  billBoard,
  searchResult,
  searchHotResult
});